<!--/**-->
<!--* 左边菜单-->
<!--*/-->
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from '../api/userMG'
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          menuname: '城市线路配置',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: 'icon-cat-skuQuery',
              menuname: '城市配置',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 3,
              icon: 'icon-cat-skuQuery',
              menuname: '城市站点配置',
              hasThird: 'N',
              url: 'siteconfig/site',
              menus: null
            },
            {
              menuid: 4,
              icon: 'icon-cat-skuQuery',
              menuname: '城市线路配置',
              hasThird: 'N',
              url: 'siteconfig/line',
              menus: null
            }, {
              menuid: 5,
              icon: 'icon-cat-skuQuery',
              menuname: '班车班次时刻表配置',
              hasThird: 'N',
              url: '',
              menus: null
            },

          ]
        },
        {
          menuid: 11,
          icon: 'li-icon-xiangmuguanli',
          menuname: '车辆管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 12,
              icon: 'icon-cat-skuQuery',
              menuname: '车辆配置',
              hasThird: 'N',
              url: 'carmag/carinfo',
              menus: null
            },
            {
              menuid: 13,
              icon: 'icon-cat-skuQuery',
              menuname: '车辆维修查看',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 14,
              icon: 'icon-cat-skuQuery',
              menuname: '车辆排班',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 15,
              icon: 'icon-cat-skuQuery',
              menuname: '城市公交运行鸟瞰图',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 16,
              icon: 'icon-cat-skuQuery',
              menuname: '停站车辆查看',
              hasThird: 'N',
              url: '',
              menus: null
            }
          ]
        },

        {
          menuid: 21,
          icon: 'li-icon-xiangmuguanli',
          menuname: '统计',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 22,
              icon: 'icon-cat-skuQuery',
              menuname: '收银统计',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 23,
              icon: 'icon-cat-skuQuery',
              menuname: '高峰期统计',
              hasThird: 'N',
              url: '',
              menus: null
            }
          ]
        },
        {
          menuid: 31,
          icon: 'li-icon-dingdanguanli',
          menuname: '模拟数据',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 32,
              icon: 'icon-order-manage',
              menuname: '模拟行车',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 33,
              icon: 'icon-order-manage',
              menuname: '模拟乘车信息',
              hasThird: 'N',
              url: '',
              menus: null
            }
          ]
        },
        {
          menuid: 41,
          icon: 'li-icon-dingdanguanli',
          menuname: '合作商配置',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 42,
              icon: 'icon-order-manage',
              menuname: '配置合作商',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 43,
              icon: 'icon-order-manage',
              menuname: '广告配置',
              hasThird: 'N',
              url: '',
              menus: null
            }
          ]
        },
        {
          menuid: 71,
          icon: 'li-icon-xitongguanli',
          menuname: '权限管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 72,
              icon: 'icon-cus-manage',
              menuname: '角色配置',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 73,
              icon: 'icon-cms-manage',
              menuname: '权限配置',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 74,
              icon: 'icon-news-manage',
              menuname: '系统账号管理',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 75,
              icon: 'icon-cs-manage',
              menuname: '乘客账户管理',
              hasThird: 'N',
              url: '',
              menus: null
            },
          ]
        },
        {
          menuid: 128,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '公告新闻',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 129,
              icon: 'icon-provider-manage',
              menuname: '公告新闻配置',
              hasThird: 'N',
              url: '',
              menus: null
            },
          ]
        },
        {
          menuid: 150,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '客服',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 151,
              icon: 'icon-provider-manage',
              menuname: '意见处理',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 152,
              icon: 'icon-provider-manage',
              menuname: '数据可视化',
              hasThird: 'N',
              url: '',
              menus: null
            },
            {
              menuid: 153,
              icon: 'icon-provider-manage',
              menuname: '在线客服',
              hasThird: 'N',
              url: '',
              menus: null
            }
          ]
        }
      ],
      msg: 'success'
    }
    this.allmenu = res.data

    // menu(localStorage.getItem('logintoken'))
    //   .then(res => {
    //     console.log(JSON.stringify(res))
    //     if (res.success) {
    //       this.allmenu = res.data
    //     } else {
    //       this.$message.error(res.msg)
    //       return false
    //     }
    //   })
    //   .catch(err => {
    //     this.$message.error('菜单加载失败，请稍后再试！')
    //   })
    // 监听
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>
